package com.example.trans.service.impl;

import com.example.trans.dao.AccountDao;
import com.example.trans.pojo.Account;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

/**
 * ClassName:IsolationService1
 * Package:com.example.trans.service.impl
 * Description:
 *
 * @Author:ZhangXin
 * @Create:2023/5/11-21:40
 * @Version:v1.0
 */
@Service("i1")
public class IsolationService1 {

    @Resource(name = "accountDao")
    private AccountDao accountDao;

    //当前事务可以读到别的事务没有提交的数据(读未提交)
//    @Transactional(isolation = Isolation.READ_UNCOMMITTED
    @Transactional(isolation = Isolation.READ_COMMITTED)//读已提交
    public void getByActno(String actno) {
        Account account = accountDao.selectByActon(actno);
        System.out.println("查询到的账户信息:" + account);
    }
}
